﻿using System.Collections.Generic;
using KMF.Common;

namespace KMF.DAL
{
    public partial class ProductCategoryBannerDb
    {
        public static List<ProductCategoryBannerHomeDto> GetListBannerByCategory(string categoryId)
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_Home_ProductCategoryBanner_GetByCate");
            try
            {
                command.Parameters.Add(dao.CreateParameter("@CategoryId", categoryId));
                var result = dao.GetDTOList<ProductCategoryBannerHomeDto>(ref command);
                return result;
            }
            finally
            {
                command.Connection.Close();
            }
        }

        public static List<ProductCategoryBannerHomeDto> GetListBannerByWidth(string categoryId,int w,int o)
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_Home_ProductCategoryBanner_GetByCateWidth");
            try
            {
                command.Parameters.Add(dao.CreateParameter("@CategoryId", categoryId));
                command.Parameters.Add(dao.CreateParameter("@Width", w));
                command.Parameters.Add(dao.CreateParameter("@Ordering", o));
                var result = dao.GetDTOList<ProductCategoryBannerHomeDto>(ref command);
                return result;
            }
            finally
            {
                command.Connection.Close();
            }
        }
        public static List<ProductCategoryBannerWidthDto> GetAllBannerByWidth(int w, int o)
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_Home_ProductCategoryBanner_GetAllByWidth");
            try
            {
                command.Parameters.Add(dao.CreateParameter("@Width", w));
                command.Parameters.Add(dao.CreateParameter("@Ordering", o));
                var result = dao.GetDTOList<ProductCategoryBannerWidthDto>(ref command);
                return result;
            }
            finally
            {
                command.Connection.Close();
            }
        }

    }
}
